<% content_for(:head) do %>
  <base href="<%= Bastion.config['relativeUrlRoot'] %>" />
<% end %>

<% content_for(:stylesheets) do %>
  <%= stylesheet_link_tag "bastion/bastion" %>
  <% Bastion.plugins.each do |name, plugin| %>
    <%= include_plugin_styles(plugin) %>
  <% end %>
<% end %>

<% content_for(:javascripts) do %>
  <%= javascript_include_tag 'bastion/bastion' %>
  <% if File.exist?("#{Bastion::Engine.root}/vendor/assets/javascripts/#{Bastion.localization_path(I18n.locale)}") %>
    <%= javascript_include_tag(Bastion.localization_path(I18n.locale)) %>
  <% end %>
  <script type="text/javascript">
    angular.module('Bastion.features').value('FeatureSettings', angular.fromJson(<%= SETTINGS[:features].nil? ? {} : SETTINGS[:features].to_json.html_safe %>));
    angular.module('Bastion').value('currentLocale', '<%= I18n.locale %>');
    angular.module('Bastion').value('CurrentOrganization', "<%= Organization.current.id if Organization.current %>");
    angular.module('Bastion').value('simpleContentAccessEnabled', <%= Organization.current.simple_content_access? if Organization.current %>);
    angular.module('Bastion').value('foreman', tfm);
    angular.module('Bastion').value('repositoryTypes', angular.fromJson('<%= Katello::RepositoryTypeManager.repository_types.values.to_json.html_safe %>'));
    angular.module('Bastion').value('deleteHostOnUnregister', angular.fromJson('<%= Setting[:unregister_delete_host] %>'));
    angular.module('Bastion').value('contentDisconnected', angular.fromJson('<%= Setting[:content_disconnected] %>'));
    angular.module('Bastion').value('globalContentProxy', angular.fromJson('<%= Setting[:content_default_http_proxy].empty? ? nil.to_json : Setting[:content_default_http_proxy].to_json.html_safe %>'));
    angular.module('Bastion').value('entriesPerPage', "<%= Setting[:entries_per_page] %>");
    angular.module('Bastion').value('contentViewSolveDependencies', "<%= Setting[:content_view_solve_dependencies] %>");
    angular.module('Bastion').constant('BastionConfig', angular.fromJson('<%= Bastion.config.to_json.html_safe %>'));
    angular.module('Bastion.auth').value('CurrentUser', {
        id: <%= User.current.id %>,
        admin: <%= User.current.admin || User.current.usergroups.any? { |group| group.admin } %>
    });
    angular.module('Bastion.auth').value('Permissions', angular.fromJson('<%= User.current.cached_roles.collect { |role| role.permissions }.flatten.to_json.html_safe %>'));
  </script>
  <% Bastion.plugins.each do |name, plugin| %>
    <%= include_plugin_js(plugin) %>
  <% end %>
<% end %>

<%= render file: "layouts/base" %>
